package com.example.springboot.config.amqp.rabbitmq.mqtt;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:ChenZhangKun
 * @Date: 2022/11/27 15:02
 */
@Configuration
public class MqttRabbitmqConfig {
    /**
     * mqtt指定的交换机名
     */
    public static final String MQTT_EXCHANGE = "amq.topic";
    public static final String MQTT_QUEUE = "mqtt_queue";
    public static final String MQTT_ROUTING_KEY = "mqtt_route_key";

    @Bean
    public Exchange exchange() {
        return new TopicExchange(MQTT_EXCHANGE);
    }

    @Bean
    public Queue queue() {
        return new Queue(MQTT_QUEUE);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(exchange()).with(MQTT_ROUTING_KEY).noargs();
    }
}
